﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ListenMusic.AdminMember_ServiceReference;
using System.ServiceModel;
namespace ListenMusic.Models.Reposistory.Admin
{
    public class ManageMemberReposistory
    {
        ManageMemberServiceClient clientAdminMember;
        public List<MembershipUserRole> getAllMembershipUser()
        {
            clientAdminMember = new ManageMemberServiceClient();
            clientAdminMember.ClientCredentials.UserName.UserName = "admin";
            clientAdminMember.ClientCredentials.UserName.Password = "123456";
            try {
                var q = from a in clientAdminMember.getAllMembershipUser()
                         where a.IsLockedOut.Equals(false)
                         select a;
                return q.ToList();                
            }
            catch (FaultException e) { throw e; }
        }
        public List<MembershipUserRole> getAllMembershipUser_isLock()
        {
            clientAdminMember = new ManageMemberServiceClient();
            clientAdminMember.ClientCredentials.UserName.UserName = "admin";
            clientAdminMember.ClientCredentials.UserName.Password = "123456";
            try
            {
                var q = from a in clientAdminMember.getAllMembershipUser()
                        where a.IsLockedOut.Equals(true)
                        select a;
                return q.ToList();
            }
            catch (FaultException e) { throw e; }
        }       
        public bool LockOrUnlockAccount(Guid userId)
        {
            clientAdminMember = new ManageMemberServiceClient();
            clientAdminMember.ClientCredentials.UserName.UserName = "admin";
            clientAdminMember.ClientCredentials.UserName.Password = "123456";
            try
            {
                return clientAdminMember.LockOrUnlockAccount(userId);
            }
            catch (FaultException e) { throw e; }
        }
    }
}